import Vue from 'vue';

export default {
	state() {
		return {
			formVisible: false,

			isEdit: false,

			rightPart: null, // null:不显示，insert:新建表单，update:更新表单，custom:自定义右边
		};
	},

	actions: {
		showInsert({ commit }) {
			commit('showIntert');
		},

		showCustom({ state }) {
			state.rightPart = 'custom';
			state.formVisible = true;
		},

		showUpdate({ state }) {
			state.rightPart = 'update';
			state.formVisible = true;
		},

		hideForm({ state }) {
			state.formVisible = false;
		},
	},

	mutations: {
		showIntert(state) {
			state.rightPart = 'insert';
			Vue.set(state, 'formVisible', true);
		},
	},

	getters: {
		formVisible: state => state.formVisible,
	},
};
